package com.htc.android.footprints.view;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.TouchDelegate;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RatingBar;
import android.widget.SeekBar;
import android.widget.TextView;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MapView.LayoutParams;
import com.htc.android.footprints.utils.FootprintUtils;
import com.htc.android.footprints.vo.Category;
import com.htc.android.footprints.vo.Footprint;
import java.util.Date;

public class DetailView extends LinearLayout
  implements View.OnClickListener
{
  private static final String TAG = "DetailView";
  private TextView addressText;
  private ImageView buttonAddress;
  private ImageView buttonLocation;
  private ImageView buttonPhone;
  private ImageView buttonWeb;
  private ImageView categoryIcon;
  private TextView categroyData;
  private TextView connectionFailedText = null;
  java.text.DateFormat df;
  java.text.DateFormat df_time;
  private ViewGroup emptyFrame;
  private ViewGroup infoFrame;
  private TextView latText;
  private ViewGroup layout;
  private TextView lonText;
  private ImageView mAddrDiv;
  private View mAddressPanel;
  private ImageView mBalloonView;
  private Category mCategory;
  private Context mContext;
  private Footprint mFootprint;
  private ImageView mLocationDiv;
  private View mLocationPanel;
  private MapView mMap;
  private ImageView mMapDiv;
  private LinearLayout mMapFrame;
  private MediaControlPanelViewMode mMediaControl;
  private ImageView mMediaDiv;
  private ImageView mPhoneDiv;
  private View mPhonePanel;
  private Bitmap mPicture;
  private ImageView mTextBoxDiv;
  private ImageView mWebDiv;
  private View mWebPanel;
  private ImageButton mapButton;
  LinearLayout.LayoutParams mapParams;
  private TouchDelegate mapTouchDelegate;
  private TextView phoneText;
  private ImageView photoView;
  private RatingBar rating;
  private HorizontalScrollView scrollView;
  private TextView textBox;
  private TextView textCreateDate;
  private TextView textCreateTime;
  private String textLatitude = "";
  private String textLongitude = "";
  private TextView textNote;
  private TextView titleText;
  private TextView webText;

  public DetailView(Context paramContext)
  {
    super(paramContext);
    this.mContext = paramContext;
    initView();
  }

  public DetailView(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    this.mContext = paramContext;
    initView();
  }

  private void initView()
  {
    long l1 = System.currentTimeMillis();
    setOrientation(1);
    this.layout = ((ViewGroup)((LayoutInflater)getContext().getSystemService("layout_inflater")).inflate(2130903049, null));
    addView(this.layout);
    this.scrollView = ((HorizontalScrollView)findViewById(2131492904));
    this.titleText = ((TextView)findViewById(2131492892));
    this.titleText.setClickable(false);
    this.categroyData = ((TextView)findViewById(2131492911));
    this.textCreateDate = ((TextView)findViewById(2131492913));
    this.textCreateTime = ((TextView)findViewById(2131492914));
    this.categoryIcon = ((ImageView)findViewById(2131492910));
    this.addressText = ((TextView)findViewById(2131492901));
    this.buttonAddress = ((ImageView)findViewById(2131492917));
    this.phoneText = ((TextView)findViewById(2131492921));
    this.webText = ((TextView)findViewById(2131492925));
    this.buttonWeb = ((ImageView)findViewById(2131492924));
    this.buttonPhone = ((ImageView)findViewById(2131492920));
    this.buttonLocation = ((ImageView)findViewById(2131492930));
    this.rating = ((RatingBar)findViewById(2131492908));
    this.mMediaControl = ((MediaControlPanelViewMode)findViewById(2131492927));
    this.latText = ((TextView)findViewById(2131492931));
    this.lonText = ((TextView)findViewById(2131492932));
    this.mMapFrame = ((LinearLayout)findViewById(2131492934));
    this.mAddressPanel = findViewById(2131492916);
    this.mPhonePanel = findViewById(2131492919);
    this.mWebPanel = findViewById(2131492923);
    this.mLocationPanel = findViewById(2131492929);
    this.mMediaDiv = ((ImageView)findViewById(2131492928));
    this.mPhoneDiv = ((ImageView)findViewById(2131492922));
    this.mWebDiv = ((ImageView)findViewById(2131492926));
    this.mAddrDiv = ((ImageView)findViewById(2131492918));
    this.textBox = ((TextView)findViewById(2131492936));
    this.photoView = ((ImageView)findViewById(2131492906));
    this.infoFrame = ((ViewGroup)findViewById(2131492915));
    this.emptyFrame = ((ViewGroup)findViewById(2131492937));
    this.df = android.text.format.DateFormat.getDateFormat(this.mContext);
    this.df_time = android.text.format.DateFormat.getTimeFormat(this.mContext);
    afterInitView();
    long l2 = System.currentTimeMillis();
    Log.d("DetailView", "initView time = " + (l2 - l1));
  }

  private void insertMap(MapView paramMapView)
  {
    this.mMap = paramMapView;
    this.mMap.removeAllViews();
    this.mMap.addView(this.mapButton, new MapView.LayoutParams(getResources().getDimensionPixelSize(2131296273), getResources().getDimensionPixelSize(2131296272), 295, 296, 85));
    this.mMap.addView(this.mBalloonView, new MapView.LayoutParams(40, 40, this.mFootprint.getPoint(), 81));
    this.mMap.getController().setCenter(this.mFootprint.getPoint());
    this.mMap.getController().setZoom(17);
    this.mMapFrame.addView(this.mMap, this.mapParams);
    this.mMap.invalidate();
    if ((!networkConnected()) && (this.connectionFailedText == null))
    {
      this.connectionFailedText = new TextView(this.mContext);
      this.connectionFailedText.setText(2131361937);
      this.connectionFailedText.setTextColor(-13421773);
      this.connectionFailedText.setPadding(10, 5, 10, 5);
      this.mMap.addView(this.connectionFailedText, new MapView.LayoutParams(-1, -2, 0, 0, 51));
    }
  }

  private boolean networkConnected()
  {
    int i = 1;
    ConnectivityManager localConnectivityManager = (ConnectivityManager)this.mContext.getSystemService("connectivity");
    if (localConnectivityManager != null)
    {
      NetworkInfo localNetworkInfo = localConnectivityManager.getActiveNetworkInfo();
      if ((localNetworkInfo == null) || (localNetworkInfo.getState() != NetworkInfo.State.CONNECTED))
        break label41;
    }
    while (true)
    {
      return i;
      label41: i = 0;
    }
  }

  private void openMapView()
  {
  }

  private void showAddressPanel(boolean paramBoolean)
  {
    if (!paramBoolean)
    {
      this.mAddressPanel.setVisibility(8);
      this.mAddrDiv.setVisibility(8);
    }
    while (true)
    {
      return;
      this.mAddressPanel.setVisibility(0);
      this.mAddrDiv.setVisibility(0);
    }
  }

  private void showMapPanel(boolean paramBoolean)
  {
    ViewGroup localViewGroup1 = (ViewGroup)findViewById(2131492933);
    ViewGroup localViewGroup2 = (ViewGroup)findViewById(2131492929);
    if (!paramBoolean)
    {
      if (this.mMapDiv != null)
        this.mMapDiv.setVisibility(8);
      localViewGroup1.setVisibility(8);
      localViewGroup2.setVisibility(8);
    }
    while (true)
    {
      return;
      if (this.mMapDiv != null)
        this.mMapDiv.setVisibility(0);
      localViewGroup1.setVisibility(0);
      localViewGroup2.setVisibility(0);
    }
  }

  private void showMediaPanel(boolean paramBoolean)
  {
    if (!paramBoolean)
    {
      this.mMediaControl.setVisibility(8);
      this.mMediaDiv.setVisibility(8);
    }
    while (true)
    {
      return;
      this.mMediaControl.setVisibility(0);
      this.mMediaDiv.setVisibility(0);
    }
  }

  private void showNotesPanel(boolean paramBoolean)
  {
    FrameLayout localFrameLayout = (FrameLayout)findViewById(2131492935);
    if (!paramBoolean)
      localFrameLayout.setVisibility(8);
    while (true)
    {
      return;
      localFrameLayout.setVisibility(0);
    }
  }

  private void showWebPanel(boolean paramBoolean)
  {
    if (!paramBoolean)
    {
      this.mWebPanel.setVisibility(8);
      this.mWebDiv.setVisibility(8);
    }
    while (true)
    {
      return;
      this.mWebPanel.setVisibility(0);
      this.mWebDiv.setVisibility(0);
    }
  }

  private void showphonePanel(boolean paramBoolean)
  {
    if (!paramBoolean)
    {
      this.mPhonePanel.setVisibility(8);
      this.mPhoneDiv.setVisibility(8);
    }
    while (true)
    {
      return;
      this.mPhonePanel.setVisibility(0);
      this.mPhoneDiv.setVisibility(0);
    }
  }

  public void afterInitView()
  {
    this.buttonAddress.setOnClickListener(this);
    this.buttonPhone.setOnClickListener(this);
    this.buttonWeb.setOnClickListener(this);
    this.buttonLocation.setOnClickListener(this);
    this.mAddressPanel.setTouchDelegate(new TouchDelegate(new Rect(0, 0, 320, 100), this.buttonAddress));
    this.mPhonePanel.setTouchDelegate(new TouchDelegate(new Rect(0, 0, 320, 100), this.buttonPhone));
    this.mWebPanel.setTouchDelegate(new TouchDelegate(new Rect(0, 0, 320, 100), this.buttonWeb));
    this.mLocationPanel.setTouchDelegate(new TouchDelegate(new Rect(0, 0, 320, 100), this.buttonLocation));
    this.mBalloonView = new ImageView(this.mContext);
    this.mBalloonView.setImageResource(2130837655);
    this.mBalloonView.setClickable(false);
    this.mapParams = new LinearLayout.LayoutParams(-1, -1);
  }

  public void checkConnectionText()
  {
    if ((this.connectionFailedText != null) && (networkConnected()))
    {
      this.mMap.removeView(this.connectionFailedText);
      this.connectionFailedText = null;
    }
  }

  public void checkMediaControl()
  {
    if (this.mMediaControl != null)
    {
      if (!FootprintUtils.checkAudioData(this.mFootprint))
        break label29;
      this.mMediaControl.setAudioData(this.mFootprint);
    }
    while (true)
    {
      return;
      label29: this.mMediaControl.disableMediaControl();
    }
  }

  public void closeMediaControl()
  {
    if (this.mMediaControl != null)
      this.mMediaControl.closeMediaPanel();
  }

  public Footprint getFootprint()
  {
    return this.mFootprint;
  }

  public HorizontalScrollView getScrollView()
  {
    return this.scrollView;
  }

  public void handleVisibleItem()
  {
    int i = 1;
    int j = 1;
    if ((this.mFootprint.mAddr != null) && (this.mFootprint.mAddr.length() > 0))
    {
      showAddressPanel(true);
      i = 0;
      j = 0;
      if ((this.mFootprint.mTel == null) || (this.mFootprint.mTel.length() <= 0))
        break label202;
      showphonePanel(true);
      i = 0;
      j = 0;
      label68: if ((this.mFootprint.mSite == null) || (this.mFootprint.mSite.length() <= 0))
        break label210;
      showWebPanel(true);
      i = 0;
      j = 0;
      label100: if (!FootprintUtils.checkAudioData(this.mFootprint))
        break label218;
      showMediaPanel(true);
      i = 0;
      j = 0;
      label119: if (this.mFootprint.mAccuracy <= 0)
        break label226;
      showMapPanel(true);
      i = 0;
      j = 0;
      label138: if (i == 0)
        break label234;
      this.infoFrame.setVisibility(8);
      label151: if ((this.mFootprint.mComment == null) || (this.mFootprint.mComment.length() <= 0))
        break label245;
      showNotesPanel(true);
      j = 0;
      label181: if (j == 0)
        break label253;
      this.emptyFrame.setVisibility(0);
    }
    while (true)
    {
      return;
      showAddressPanel(false);
      break;
      label202: showphonePanel(false);
      break label68;
      label210: showWebPanel(false);
      break label100;
      label218: showMediaPanel(false);
      break label119;
      label226: showMapPanel(false);
      break label138;
      label234: this.infoFrame.setVisibility(0);
      break label151;
      label245: showNotesPanel(false);
      break label181;
      label253: this.emptyFrame.setVisibility(8);
    }
  }

  public void onClick(View paramView)
  {
    if (paramView == this.buttonPhone)
    {
      Intent localIntent1 = new Intent("android.intent.action.CALL");
      localIntent1.setData(Uri.parse("tel:" + this.mFootprint.mTel));
      localIntent1.setFlags(268435456);
      getContext().startActivity(localIntent1);
    }
    while (true)
    {
      return;
      if (paramView == this.buttonAddress)
      {
        if (this.mFootprint.mAccuracy <= 0)
          continue;
        StringBuffer localStringBuffer = new StringBuffer();
        localStringBuffer.append("geo:0,0?q=").append("+").append(this.mFootprint.mAddr);
        Intent localIntent4 = new Intent("android.intent.action.VIEW", Uri.parse(localStringBuffer.toString()));
        getContext().startActivity(localIntent4);
        continue;
      }
      if (paramView == this.buttonLocation)
      {
        if (this.mFootprint.mAccuracy <= 0)
          continue;
        double d1 = this.mFootprint.mLatitude / 1000000.0D;
        double d2 = this.mFootprint.mLongitude / 1000000.0D;
        Intent localIntent3 = new Intent("android.intent.action.VIEW", Uri.parse("geo:" + String.valueOf(d1) + "," + String.valueOf(d2) + "?z=" + String.valueOf(15)));
        getContext().startActivity(localIntent3);
        continue;
      }
      if ((paramView != this.buttonWeb) || (this.mFootprint.mSite.length() < 5))
        continue;
      String str = "";
      if ((!this.mFootprint.mSite.toLowerCase().startsWith("http:")) && (!this.mFootprint.mSite.toLowerCase().startsWith("https:")))
        str = "http://";
      Intent localIntent2 = new Intent("android.intent.action.VIEW", Uri.parse(str + this.mFootprint.mSite));
      getContext().startActivity(localIntent2);
    }
  }

  public void removeMap(MapView paramMapView)
  {
    this.mMapFrame.removeView(this.mMap);
  }

  public void scrollToTop()
  {
    this.scrollView.scrollTo(0, 0);
  }

  public void setCategory(Category paramCategory)
  {
    this.mCategory = paramCategory;
  }

  public void setFootprint(Footprint paramFootprint)
  {
    this.mFootprint = paramFootprint;
  }

  public void setLocationString(String paramString1, String paramString2)
  {
    this.textLatitude = paramString1;
    this.textLongitude = paramString2;
  }

  public void setMapButton(ImageButton paramImageButton)
  {
    this.mapButton = paramImageButton;
    this.mapTouchDelegate = new TouchDelegate(new Rect(0, 0, 320, 480), this.mapButton);
    this.mMapFrame.setTouchDelegate(this.mapTouchDelegate);
  }

  public void setPicture(Bitmap paramBitmap)
  {
    this.mPicture = paramBitmap;
  }

  public void updateViewAfterSwitch(MapView paramMapView)
  {
    this.addressText.setText(this.mFootprint.mAddr);
    ImageView localImageView1 = this.buttonAddress;
    boolean bool1;
    boolean bool2;
    label82: boolean bool3;
    label135: ImageView localImageView4;
    if (this.mFootprint.mAccuracy > 0)
    {
      bool1 = true;
      localImageView1.setEnabled(bool1);
      this.phoneText.setText(this.mFootprint.mTel);
      ImageView localImageView2 = this.buttonPhone;
      if ((this.mFootprint.mTel == null) || (this.mFootprint.mTel.length() <= 0))
        break label305;
      bool2 = true;
      localImageView2.setEnabled(bool2);
      this.webText.setText(this.mFootprint.mSite);
      ImageView localImageView3 = this.buttonWeb;
      if ((this.mFootprint.mSite == null) || (this.mFootprint.mSite.length() <= 0))
        break label311;
      bool3 = true;
      localImageView3.setEnabled(bool3);
      localImageView4 = this.buttonLocation;
      if (this.mFootprint.mAccuracy <= 0)
        break label317;
    }
    label305: label311: label317: for (boolean bool4 = true; ; bool4 = false)
    {
      localImageView4.setEnabled(bool4);
      this.latText.setText(this.textLatitude);
      this.lonText.setText(this.textLongitude);
      this.textBox.setText(this.mFootprint.mComment);
      this.mMediaControl.setAudioData(this.mFootprint);
      ImageView localImageView5 = (ImageView)this.mMediaControl.findViewById(2131492992);
      SeekBar localSeekBar = (SeekBar)this.mMediaControl.findViewById(2131493001);
      if (!localImageView5.isEnabled())
        localImageView5.setEnabled(true);
      if (!localSeekBar.isEnabled())
        localSeekBar.setEnabled(true);
      this.mMediaControl.invalidate();
      if (this.mFootprint.mAccuracy > 0)
        insertMap(paramMapView);
      invalidate();
      return;
      bool1 = false;
      break;
      bool2 = false;
      break label82;
      bool3 = false;
      break label135;
    }
  }

  public void updateViewBeforeSwitch()
  {
    this.titleText.setText(this.mFootprint.mName);
    if (this.mPicture != null)
      this.photoView.setImageBitmap(this.mPicture);
    String str;
    boolean bool1;
    label194: boolean bool2;
    label244: boolean bool3;
    label296: ImageView localImageView4;
    if (this.mCategory != null)
    {
      TextView localTextView = this.categroyData;
      if (this.mCategory.mName != null)
      {
        str = this.mCategory.mName;
        localTextView.setText(str);
        this.categoryIcon.setImageDrawable(FootprintUtils.getCategoryIcon(this.mContext, this.mCategory.mKeyword));
      }
    }
    else
    {
      this.rating.setRating(this.mFootprint.mRate);
      this.textCreateDate.setText(this.df.format(new Date(this.mFootprint.mCreateTime)));
      this.textCreateTime.setText(this.df_time.format(new Date(this.mFootprint.mCreateTime)));
      this.addressText.setText(this.mFootprint.mAddr);
      ImageView localImageView1 = this.buttonAddress;
      if (this.mFootprint.mAccuracy <= 0)
        break label400;
      bool1 = true;
      localImageView1.setEnabled(bool1);
      this.phoneText.setText(this.mFootprint.mTel);
      ImageView localImageView2 = this.buttonPhone;
      if ((this.mFootprint.mTel == null) || (this.mFootprint.mTel.length() <= 0))
        break label405;
      bool2 = true;
      localImageView2.setEnabled(bool2);
      this.webText.setText(this.mFootprint.mSite);
      ImageView localImageView3 = this.buttonWeb;
      if ((this.mFootprint.mSite == null) || (this.mFootprint.mSite.length() <= 0))
        break label411;
      bool3 = true;
      localImageView3.setEnabled(bool3);
      localImageView4 = this.buttonLocation;
      if (this.mFootprint.mAccuracy <= 0)
        break label417;
    }
    label400: label405: label411: label417: for (boolean bool4 = true; ; bool4 = false)
    {
      localImageView4.setEnabled(bool4);
      this.latText.setText(this.textLatitude);
      this.lonText.setText(this.textLongitude);
      this.textBox.setText(this.mFootprint.mComment);
      this.mMediaControl.setAudioData(this.mFootprint);
      checkMediaControl();
      checkConnectionText();
      handleVisibleItem();
      invalidate();
      return;
      str = "";
      break;
      bool1 = false;
      break label194;
      bool2 = false;
      break label244;
      bool3 = false;
      break label296;
    }
  }
}

/* Location:           E:\workspace\dex2java\dex-translator-0.0.9.3\HtcFootprints_dex2jar.jar
 * Qualified Name:     com.htc.android.footprints.view.DetailView
 * JD-Core Version:    0.6.0
 */